﻿using System;
using System.Windows.Data;

namespace Ags.MonsterTools.PingTool
{
    public class MilisecondsToSecondsConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int wert;
            if (int.TryParse(value.ToString(), out wert))
            {
                return ((wert/1000) < 1 ? 0 : (wert/1000)) + " sec";
            }
            else
            {
                return Binding.DoNothing;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int wert;
            if (int.TryParse(value.ToString(), out wert))
            {
                return wert*1000;
            }
            else
            {
                return Binding.DoNothing;
            }
        }
    }
}
